package com.linqi.freebie.http.ktorClientCio.interceptor

import io.ktor.client.plugins.api.createClientPlugin

fun InterceptorChainPlugin(interceptors: List<HttpInterceptor>) =
    createClientPlugin(name = "InterceptorChainPlugin") {
        onRequest { request, _ ->
            for (interceptor in interceptors) {
                interceptor.onRequest(request)
            }
        }
        onResponse { response ->
            for (interceptor in interceptors) {
                interceptor.onResponse(response)
            }
        }
    }
